<template>
  <div>
    <van-nav-bar title="登录" left-arrow @click-left="onClickLeft" />

    <van-field v-model="ruleForm.phone" type="tel" label="手机号" />
    <van-field v-model="ruleForm.password" type="password" label="密码" />

    <van-button
      type="info"
      class="ip"
      @click="submitForm"
      color="blue"
      round
      size="large"
      >提交</van-button
    >
    <div class="k" @click="pushd">没有账号，立即注册</div>
  </div>
</template>

<script>
import { login } from "../radio/index";
export default {
  data() {
    return {
      ruleForm: {
        phone: "123456789",
        password: 123456,
      },
    };
  },
  methods: {
    pushd() {
      this.$router.push("/zhuce");
    },

    async submitForm() {
      let res = await login(this.ruleForm);
      console.log(res);
      if (res.code == 200) {
        this.$store.commit("getlogin", res.list);
        this.$toast("登录成功");
        this.$router.push("/index/shouye");
      } else {
        alert(res.msg);
      }
    },
    onClickLeft(){
      this.$router.push("/zhuce");
    }
  },
};
</script>

<style>
.ip {
  margin-top: 20px;
}
.k {
  margin: 30px 0 0 110px;
  color: #0000ee;
}
</style>